Skip to content

Make SQA store SQLAlchemy 2.0-compatible#5201

Open
LeoMoonStar wants to merge 1 commit into
facebook:mainfrom
LeoMoonStar:export-D104875017
Open

Make SQA store SQLAlchemy 2.0-compatible#5201
LeoMoonStar wants to merge 1 commit into
facebook:mainfrom
LeoMoonStar:export-D104875017

Conversation

@LeoMoonStar
Copy link
Copy Markdown

@LeoMoonStar LeoMoonStar commented May 14, 2026

The Ax SQA store has a hard guard in with_db_settings_base.py that raises IncompatibleDependencyVersion when SQLAlchemy major > 1, disabling SQL storage entirely. This blocks SA 2.0 adoption and Python 3.13/3.14, which install SA 2.x by default. Two additional SA 2.0 incompatibilities exist:
defer("col_name") in load.py and reduced_state.py, which SA 2.0 rejects in favor of class-bound attribute references.

This change removes the guard and converts the string-based loader options to attribute references. Adds TestSQLAlchemyDualVersionCompat which
(a) asserts DBSettings resolves to the real class type whenever SQLAlchemy is importable (proving the guard is gone) and
(b) optionally asserts the runtime SQLAlchemy
major matches an EXPECTED_SA_MAJOR env var, for CI matrices that pin a specific SQLAlchemy version.

Summary:
The OSS Ax SQA store has a hard guard in with_db_settings_base.py that raises IncompatibleDependencyVersion when SQLAlchemy major > 1, disabling SQL storage entirely. This blocks SA 2.0 adoption (T163607006) and Python 3.13/3.14 (which auto-select SA 2.0.48 from third-party). Two additional SA 2.0 incompatibilities exist in OSS: defer("col_name") in load.py and reduced_state.py, which SA 2.0 rejects in favor of class-bound attribute references.

This diff removes the guard and converts the string-based loader options to attribute references. Adds a dual-version Buck test target tests_sa2 via constraint_overrides plus a self-proving TestSQLAlchemyDualVersionCompat class so each target proves its constraint took effect (EXPECTED_SA_MAJOR env var asserted at runtime).

Differential Revision: D104875017
@meta-cla meta-cla Bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label May 14, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented May 14, 2026

@LeoMoonStar has exported this pull request. If you are a Meta employee, you can view the originating Diff in D104875017.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant